#ifndef _DEFINES_H_
#define _DEFINES_H_

#include <stdint.h>

/*********************************
 * 所有全局变量只在 ElectricOilPump_SpecialParse 中被修改
 *********************************/

/********************************
 * 速度或扭矩升降不允许突变，以免损坏电控及电机，需要按照步长升降
 ********************************/
#define G_MOTOR_SPEED_RISE_REDUCE_STEP 2 //速度升降步长
#define G_MOTOR_TORQUE_RISE_REDUCE_STEP 5 //扭矩升降步长

#define G_MOTOR_SPEED_MAX_LIMIT 2500 //速度最大值


#define G_CANTIMEOUT_SECONDS 2 //CAN超时秒数

/***************************************
 * MCU使能状况
 **************************************/
#define G_RUNNINGENABLE_DISABLE 0x00 //禁能
#define G_RUNNINGENABLE_CLEARFAULT 0x01 //清故障
#define G_RUNNINGENABLE_ENABLE 0x02 //使能

/***************************************
 * 控制模式
 **************************************/
#define G_MOTOR_CONTROLMODE_FREE 0x00 //自由转
#define G_MOTOR_CONTROLMODE_TORQEU 0x01 //转矩模式
#define G_MOTOR_CONTROLMODE_SPEED 0x02 //转速模式



extern uint8_t g_ForbidMotorFrame; //0-continue send,1-get ask an then send
extern int16_t g_ActualPower; //功率
extern int16_t g_ActualTotalEnergy; //能耗

extern uint8_t g_ControlMode; //control mode
extern uint8_t g_RunningEnable; //running enable
extern int16_t g_MotorMcuRunSpeed; //MCU当前速度
extern int16_t g_MotorTargetSpeed; //目标速度
extern int16_t g_MotorReadSpeed; //实际A4964读取速度
extern uint8_t g_MotorTorque; //torque,0-32

extern int16_t g_WindingTemperature; //motor winding temperature
extern int16_t g_InverterTemperature; //mtcl inverter temperature
extern int16_t g_MtclChipTemperature; //mtcl chip a4964 temperature
extern uint16_t g_DcVoltage;
extern uint8_t g_DcCurrent;
extern uint16_t g_AcVoltage;
extern uint8_t g_AcCurrent;
extern uint16_t g_McuInputVoltage; //MCU Voltage

extern uint8_t g_ErrorLevel;
extern uint8_t g_ErrorCode;

//version
extern uint8_t g_Version_Year;
extern uint8_t g_Version_Month;
extern uint8_t g_Version_Day;
extern uint8_t g_Version_Hour;
extern uint8_t g_Version_Minute;

//A4964寄存器0-28，共29个寄存器值
extern uint16_t g_A4964_RegisterValues[29];

#endif